<!-- 模板 -->
<template>
  <div class="">
    <div>{{ $store.state.a }}</div>
    <div>
      <button @click="addA">addA</button>
      <button @click="sub(100)">subA</button>
    </div>
  </div>
</template>

<script>
// import component from '@/components/*.vue'
import { mapActions, mapMutations } from 'vuex'
export default {
  name: '',
  data() {
    return {}
  },
  props: [],
  components: {},
  computed: {},
  filters: {},
  methods: {
    // addA() {
    //   //dispatch调用的是actions中的函数，是异步执行
    //   this.$store.dispatch('addA')
    // },
    // sub() {
    //   //commit调用的是mutations中的函数，是同步执行
    //   this.$store.commit('sub', 100)
    // }
    ...mapMutations(['sub']),
    ...mapActions(['addA'])
  },
  created() {},
  mounted() {}
}
</script>

<style lang="less" scoped>
//@import url(); 引入公共css类
</style>
